<template>
	<view class="wrap">
		<view class="banner">
			
		</view>
		<view class="inner-wrap">
			<view class="info-wrap">
				<view class="title">
					{{pageData.name}}
				</view>
				<view class="price" v-show="pageData.price">
					￥{{pageData.price}}
				</view>
			</view>
			<view class="main-page">
				<view class="list-wrap">
					<view class="left">
						<view>单股价格</view>
						
					</view>
					<view class="right">{{pageData.single_equity_price}}</view>
				</view>
				<view class="list-wrap">
					<view class="left">
						<view>有效股权</view>
						
					</view>
					<view class="right">{{pageData.effective_equity}}</view>
				</view>
				<!-- <view class="list-wrap" >
					<view class="left">
						<view>有效算力</view>
						
					</view>
					<view class="right" v-show="pageData.effective_force">{{pageData.effective_force}}/天</view>
				</view> -->
				<view class="list-wrap">
					<view class="left">
						<view>总产出</view>
						
					</view>
					<view class="right">{{pageData.total_output}}</view>
				</view>
				
				
				<!-- <view class="list-wrap" >
					<view class="left">
						<view>封装周期</view>
						
					</view>
					<view class="right" v-show="pageData.cycle">{{pageData.cycle}}天</view>
				</view> -->
				<view class="list-wrap" >
					<view class="left">
						<view>产权有效</view>
						
					</view>
					<view @click="entershuoming('../hangyezixundetail/index')" class="right shuoming" v-show="pageData.property">{{pageData.property}}</view>
				</view>
				<view class="list-wrap" >
					<view class="left">
						<view>产品</view>
						
					</view>
					<view class="right">{{pageData.product_name}}</view>
				</view>
			</view>
		</view>
		<view class="btn-wrap">
			<view class="price">
				<view class="label">
					总计：
				</view>
				<view v-show="pageData.total" class="price">{{pageData.total}} ￥</view>
			</view>
			<view v-show="pageData.product_name" class="sub-btn" @click="enterpage('../goumaidetail/index')">
				立即买入
			</view>
		</view>
	</view>
</template>

<script>
	function parseQueryString(url){
		if(url.split("?").length==1){
			return {
				urls:url
			}
		}
	      var str=url.split("?")[1];
	       var iterms = str.split("&");
	       var arr,Json={};
	       for(var i=0;i<iterms.length;i++){
	               arr=iterms[i].split("=");
	               Json[arr[0]]=arr[1];
	       }
		   Json.urls=url.split("?")[0]
	       return Json;
	}
	export default {
		data() {
			return {
				id:'',
				pageData:{}
			}
		},
		// onShow() {
		// 	this.getData()
		// },
		onLoad(options) {
			this.id=options.id
			this.getData()
		},
		methods: {
			getData(){
				let that=this
				that.apipost('/api/home/equity_info',{id:that.id},true).then(res => {
					if(res.Code==10200){
						
						let data=res.Data
						that.pageData=data
					}
					
				}).catch(err=>{
					console.log(err)
				});
			},
			entershuoming(path){
				if(!this.pageData.property_link){
					return
				}
				let urlPas=parseQueryString(this.pageData.property_link)
				let stringUrl='lk=12'
				for(let items in urlPas){
					stringUrl+='&'+items+'='+urlPas[items]
				}
				uni.navigateTo({
				    url: `${path}?${stringUrl}`
				});
			},
			enterpage(path){
				if(path){
					uni.navigateTo({
					    url: path+`?id=${this.pageData.product_id}`
					});
				}else{
					uni.showToast({
					    title: '暂未开放',
					    duration:4000,
						icon:'none'
					});
				}
			}
		}
	}
</script>

<style>
	.btn-wrap .sub-btn{
		width:286rpx;
		height:74rpx;
		border-radius:40rpx;
		color:#fff;
		background:#4167ec;
		display:flex;
		align-items: center;
		justify-content: center;
	}
	.btn-wrap .price{
		color:#4167ec;
		display:flex;
		align-items: center;
		padding-left:19rpx;
	}
	.shuoming{
		text-decoration: underline;
	}
	.btn-wrap .label{
		color:#333;
		display:flex;
		align-items: center;
		padding-left:50rpx;
	}
	.main-page{
		padding:0 30rpx;
		background:#fff;
		border-bottom-left-radius:12rpx;
		border-bottom-right-radius: 12rpx;
	}
	.list-wrap img{
		width:30rpx;
		margin-left:14rpx;
	}
	.list-wrap .left{
		display:flex;
		align-items: center;
	}
	.list-wrap .right{
		color:#4167ec;
		padding-right:22rpx;
	}
	.list-wrap{
		justify-content: space-between;
		padding-left:16rpx;
		height:102rpx;
		display:flex;
		align-items: center;
		color:#333;
		background:#fff;
		border-bottom:2rpx solid #e9e9e9;
	}
	.info-wrap .title{
		padding-top:56rpx;
		padding-bottom:66rpx;
	}
	.banner{
		height:296rpx;
		background: url(../../static/guquangoumaibg1.png) no-repeat;
		background-size:100% 100%;
	}
	.info-wrap{
		color:#fff;
		padding-left:50rpx;
		box-sizing: border-box;
		position:absolute;
		height:244rpx;
		
		background: url(../../static/guquangoumaibg2.png) no-repeat;
		background-size:100% 100%;
		width:100%;
		top:-180rpx;
		border-top-left-radius:12rpx;
		border-top-right-radius: 12rpx;
	}
	.inner-wrap{
		padding-top:66rpx;
		position:relative;
		width:710rpx;
		margin:0 auto;
	}
	.btn-wrap{
		display:flex;
		align-items: center;
		justify-content: space-between;
		height:142rpx;
		background:#fff;
		width:100%;
		position:fixed;
		bottom:0;
	}
	.wrap{
		background:#f7f7f7;
		min-height:100%;
	}
</style>
